using System;
#if !PocketPC
using System.Runtime.Serialization;
#endif

using GeoFramework;

namespace GeoFramework.IO
{
	/// <summary>
	/// Represents information about an Text sentence processing error.
	/// </summary>
#if !PocketPC
    [Serializable()]
#endif
	public class PacketException : Exception
	{
		private Packet pPacket;

		public PacketException() : base()
		{
		}
	
		public PacketException(Packet packet, string message) : base(message)
		{
			pPacket = packet;
		}
	
		public PacketException(Packet packet, string message, Exception innerException) : base(message, innerException)
		{
			pPacket = packet;
		}
	
#if !PocketPC
        protected PacketException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        { }
#endif

		public Packet Packet
		{
			get
			{
				return pPacket;
			}
		}

	}

	public class PacketExceptionEventArgs : ExceptionEventArgs
	{
//		private PacketException sPacketException;

		public new static readonly PacketExceptionEventArgs Empty = new PacketExceptionEventArgs(null);

		public PacketExceptionEventArgs(PacketException exception)
			: base(exception)
		{
//			sPacketException = exception;
		}

		public Packet Packet
		{
			get
			{
				return ((PacketException)Exception).Packet;
			}
		}
	}

	public delegate void PacketExceptionEventHandler(object sender, PacketExceptionEventArgs e);

}
